We are migrating the bug tracker to github Issues. This is now the preferred way to report NASM bugs.

Self-registration is disabled due to spam issue (mail gorcunov@gmail.com or hpa@zytor.com to create an account)

Bug 3392924 - (-f obj) Label defined (after assembling anything) then declared EXTERN causes "inconsistently redefined" error
Summary: (-f obj) Label defined (after assembling anything) then declared EXTERN cause...
Status: CLOSED FIXED
Alias: None
Product: NASM
Classification: Unclassified
Component: Assembler (show other bugs)
Version: 2.16.xx
Hardware: All All
: Medium critical
Assignee: nobody
URL:
Depends on:
Blocks:
 
Reported: 2024-11-13 11:30 PST by E. C. Masloch
Modified: 2025-09-19 14:30 PDT (History)
5 users (show)

Obtained from: Built from git using configure
Generated by: Human
Bug category: Incorrect main output, Unexpected or confusing behavior
Observed for: Development code
Regression: No
Regression since:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description E. C. Masloch 2024-11-13 11:30:30 PST
During my work porting MS-DOS v4.01's msdos kernel module I came across an error. When something is assembled into a section (anything, eg "nop") then a label is defined and afterwards the same label is declared EXTERN, NASM emits an error. Note that when the label is defined as EXTERN first, then defined, and then declared EXTERN again it works. Not assembling anything into the current section before the label line also seems to avoid the error, but is obviously not a useful workaround.

Test cases:

test$ nasm -v
NASM version 2.16.02rc2 compiled on Oct 12 2023
test$ cat test1.asm
nop
label:
extern label
test$ cat test2.asm
nop
extern label
label:
extern label
test$ cat test3.asm
label:
extern label
test$ nasm -f obj test1.asm
test1.asm:3: error: label `label' inconsistently redefined
test1.asm:2: info: label `label' originally defined here
test$ nasm -f obj test2.asm
test$ nasm -f obj test3.asm
test$
Comment 1 H. Peter Anvin 2025-09-19 14:22:58 PDT
Fix checked in, will be in NASM 3.00rc9.
Comment 2 E. C. Masloch 2025-09-19 14:30:19 PDT
Thanks, I tested it and it's fine now.